﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GDD2_Game3
{
    class GameUpdate : IUpdate
    {
        private Game1 game1;
		private GameData gameData;

		public GameUpdate(Game1 g1, GameData data)
        {
			game1 = g1;
			gameData = data;
        }

        public void update(GameTime gameTime)
        {
			game1.setScreenDimensions(gameData.ScreenWidth, gameData.ScreenHeight);
            //moving vehicle
			gameData.Vehicle.move(leftHeld(), rightHeld(), upHeld(), downHeld(), /*gameData.Track.collisions(gameData.Vehicle)*/ gameData.Track.Walls, Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds));
        }

		private bool leftHeld()
		{
			return Keyboard.GetState().IsKeyDown(Keys.Left) || Keyboard.GetState().IsKeyDown(Keys.A);
		}

		private bool rightHeld()
		{
			return Keyboard.GetState().IsKeyDown(Keys.Right) || Keyboard.GetState().IsKeyDown(Keys.D);
		}

		private bool upHeld()
		{
			return Keyboard.GetState().IsKeyDown(Keys.Up) || Keyboard.GetState().IsKeyDown(Keys.W);
		}

		private bool downHeld()
		{
			return Keyboard.GetState().IsKeyDown(Keys.Down) || Keyboard.GetState().IsKeyDown(Keys.S);
		}
    }
}
